feat: use gradual 1.5x backoff for Stellar resubmission#730
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThe PR refactors Stellar transaction resubmission timing by introducing a configurable growth factor parameter (1.5) for backoff intervals. It reduces the base interval from 15s to 10s, caps the maximum at 120s, and replaces the exponential backoff algorithm with a tiered growth mechanism. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
Updates Stellar transaction resubmission timing to retry sooner and more frequently by switching from 2x exponential backoff to a gradual 1.5x growth backoff with a lower cap.
Changes:
- Add
growth_factortocompute_resubmit_backoff_interval()and implement gradual tiered backoff (capped). - Update Stellar status handlers to use the new backoff parameters/constants.
- Adjust Stellar resubmission constants (base interval 10s, cap 120s) and update unit tests accordingly.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/domain/transaction/stellar/utils.rs |
Implements growth-factor-based backoff and updates/adds unit tests. |
src/domain/transaction/stellar/status.rs |
Passes growth factor into backoff computation and updates related test expectations/comments. |
src/constants/stellar_transaction.rs |
Updates resubmission timing constants and introduces STELLAR_RESUBMIT_GROWTH_FACTOR. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/domain/transaction/stellar/status.rs`:
- Around line 454-465: The backoff tier is being computed from total_age
(get_age_since_created) but compared to age_since_last_submit
(get_age_since_sent_or_created), causing tiers to jump after sent_at is updated;
change the logic in the resubmit path (the block using
compute_resubmit_backoff_interval with STELLAR_RESUBMIT_BASE_INTERVAL_SECONDS /
_MAX_INTERVAL_SECONDS / _GROWTH_FACTOR) so the tier is derived from
age_since_last_submit (or from an explicit retry counter / persisted retry_tier
on the transaction) rather than created_at; ensure
compute_resubmit_backoff_interval is called with the correct age input (or
replace it by computing the next interval from retry count/previous interval)
and apply the resulting backoff check against age_since_last_submit, and mirror
the same fix at the other occurrence around lines 603-613 to keep behavior
consistent.
In `@src/domain/transaction/stellar/utils.rs`:
- Around line 1325-1344: Add an early guard that rejects non-positive
base_interval_secs before using it in the loop: check if base_interval_secs <= 0
and return None (or otherwise signal invalid input) so tier_end and interval are
never initialized with zero/negative values; update the helper that uses
base_interval_secs, growth_factor, max_interval_secs, tier_end and interval to
perform this guard immediately after the existing age_secs check and before
computing interval/tier_end.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a3354b4c-f830-49b7-b92a-dfac45a53f2b
📒 Files selected for processing (3)
src/constants/stellar_transaction.rssrc/domain/transaction/stellar/status.rssrc/domain/transaction/stellar/utils.rs
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. @@ Coverage Diff @@
## main #730 +/- ##
==========================================
+ Coverage 90.20% 90.24% +0.04%
==========================================
Files 289 289
Lines 120730 121302 +572
==========================================
+ Hits 108905 109474 +569
- Misses 11825 11828 +3
🚀 New features to boost your workflow:
|
- Use half-open intervals in doc comments to match tier boundary behavior - Guard non-positive base_interval_secs and max_interval_secs (return None) - Rename test to reflect min(base, max) fallback for invalid growth factor - Fix "exponential backoff" wording in constants doc comment Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
growth_factorparameter tocompute_resubmit_backoff_interval()with guard against infinite loops when factor ≤ 1.0Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
Chores